<<<<<<< HEAD
package com.example.zhangfeng.commondemo.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.example.zhangfeng.commondemo.R;

/**
 * Created by zhangfeng on 2016/4/28.
 * Activity界面的父类
 */
public abstract class BaseActivity extends AppCompatActivity {

    private String title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setWantShowContentView();

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        TextView tvTitle= (TextView) toolbar.findViewById(R.id.tv_title);

        toolbar.setTitle("");
        tvTitle.setText(title);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        //setNavigationIcon需要放在 setSupportActionBar之后才会生效。
        toolbar.setNavigationIcon(R.drawable.left_icon);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    public void setToolbarTitle(String title) {
        this.title = title;
    }

    public abstract void setWantShowContentView();
}
=======
package com.example.zhangfeng.commondemo.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.example.zhangfeng.commondemo.R;

/**
 * Created by zhangfeng on 2016/4/28.
 * Activity界面的父类
 */
public abstract class BaseActivity extends AppCompatActivity {

    private String title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setWantShowContentView();

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        TextView tvTitle= (TextView) toolbar.findViewById(R.id.tv_title);

        toolbar.setTitle("");
        tvTitle.setText(title);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        //setNavigationIcon需要放在 setSupportActionBar之后才会生效。
        toolbar.setNavigationIcon(R.drawable.left_icon);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    public void setToolbarTitle(String title) {
        this.title = title;
    }

    public abstract void setWantShowContentView();
}
>>>>>>> 12b9a08f9380bce72b8c6e055d4084faa0570803
